// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space 
// Source File Name:   ResourceServiceImpl.java

package com.hfstu.pms.dataaccess.service.impl;

import com.google.common.collect.*;
import com.hfstu.framework.util.StringUtil;
import com.hfstu.ifs.dataaccess.dao.*;
import com.hfstu.ifs.dataaccess.service.tree.TreeNavigationTree;
import com.hfstu.ifs.dto.*;
import com.hfstu.ifs.model.*;
import com.hfstu.pms.common.PmsCombinationType;
import com.hfstu.pms.common.PmsResourceType;
import com.hfstu.pms.dataaccess.dao.IPmsResourceDao;
import com.hfstu.pms.dataaccess.dao.IUserDao;
import com.hfstu.pms.dataaccess.service.IResourceService;
import com.hfstu.pms.dataaccess.service.tree.ResourceTree;
import com.hfstu.pms.model.*;
import java.io.Serializable;
import java.util.*;

public class ResourceServiceImpl
	implements IResourceService
{

	private static final String IDS_SPLIT = "_";
	private INodeSystemDao nodeSystemDao;
	private IMenuDao menuDao;
	private IMenuBindNavDao menuBindNavDao;
	private IControlRegisterDao controlRegisterDao;
	private INavControlDao navControlDao;
	private IControlFuncDao controlFuncDao;
	private IFuncLayoutDao funcLayoutDao;
	private ITreeNavigationDao treeNavigationDao;
	private IListNavigationDao listNavigationDao;
	private IPmsResourceDao pmsResourceDao;
	private IUserDao userDao;

	public ResourceServiceImpl()
	{
	}

	private List getRoleIdsByUserId(String userId)
	{
		List roleIds = Lists.newArrayList();
		User user = (User)userDao.getById(userId);
		Set roles = user.getRoles();
		if (roles != null)
		{
			Role role;
			for (Iterator iterator = roles.iterator(); iterator.hasNext(); roleIds.add(role.getId()))
				role = (Role)iterator.next();

		}
		return roleIds;
	}

	public List getPmsNodeSystemList(String userId)
	{
		List nodeSystemDTOs = Lists.newArrayList();
		Map filterPropertyMap = Maps.newHashMap();
		filterPropertyMap.put("pmsResource.combinationType", PmsCombinationType.ROLE_RESOURCE.getKey());
		filterPropertyMap.put("pmsResource.nodeId", userId);
		List pmsResources = pmsResourceDao.findListByCondition(filterPropertyMap, null);
		Set systemCodes = Sets.newHashSet();
		PmsResource pmsResource;
		for (Iterator iterator = pmsResources.iterator(); iterator.hasNext(); systemCodes.add(pmsResource.getSystemCode()))
			pmsResource = (PmsResource)iterator.next();

		Map filterPropertyMaps = Maps.newHashMap();
		filterPropertyMaps.put("nodeSystem.codes", ((Object) (systemCodes.toArray(new String[systemCodes.size()]))));
		List nodeSystems = nodeSystemDao.findListByCondition(filterPropertyMaps, null);
		NodeSystem nodeSystem;
		for (Iterator iterator1 = nodeSystems.iterator(); iterator1.hasNext(); nodeSystemDTOs.add((new NodeSystemDTO()).transfer(nodeSystem)))
			nodeSystem = (NodeSystem)iterator1.next();

		return nodeSystemDTOs;
	}

	public NodeSystemDTO getPmsNodeSystemMenu(String userId, String nodeSystemCode)
	{
		NodeSystemDTO nodeSystemDTO = new NodeSystemDTO();
		nodeSystemDTO.transfer(nodeSystemDao.getByCode(nodeSystemCode));
		User user = (User)userDao.getById(userId);
		if (user == null)
			return nodeSystemDTO;
		boolean pmsControl = true;
		StringBuffer roleStr = new StringBuffer();
		Set pmsMenuBindNavIds = Sets.newHashSet();
		if (com.hfstu.pms.model.User.UserSuperAdminEnum.ADMIN.getKey().equals(String.valueOf(user.getSuperAdmin() != null ? ((Object) (user.getSuperAdmin())) : "null")))
		{
			pmsControl = false;
		} else
		{
			Set roles = user.getRoles();
			if (roles != null)
			{
				Role role;
				for (Iterator iterator = roles.iterator(); iterator.hasNext(); roleStr.append(role.getId()).append(","))
					role = (Role)iterator.next();

				if (!StringUtil.isNullOrEmpty(roleStr.toString()) && roleStr.charAt(roleStr.length() - 1) == ',')
					roleStr.deleteCharAt(roleStr.length() - 1);
			}
		}
		Map queryMap = Maps.newHashMap();
		queryMap.put("sd.code", nodeSystemCode);
		if (pmsControl)
		{
			Map resourceMap = loadHasPms(roleStr.toString(), nodeSystemCode, PmsCombinationType.ROLE_RESOURCE.getKey(), null);
			Set menuIds = (Set)resourceMap.get(PmsResourceType.MENU.getKey());
			pmsMenuBindNavIds = (Set)resourceMap.get(PmsResourceType.MENUNAV.getKey());
			if (menuIds == null || menuIds.size() == 0)
				queryMap.put("menu.ids", new String[] {
					"-1"
				});
			else
				queryMap.put("menu.ids", ((Object) (menuIds.toArray(new String[menuIds.size()]))));
		}
		Map sortMap = Maps.newHashMap();
		sortMap.put("menu.orderIndex", "ASC");
		List menuLists = menuDao.findListByCondition(queryMap, sortMap);
		List menuDTOLists = Lists.newArrayList();
		if (menuLists != null && menuLists.size() != 0)
		{
			for (Iterator iterator1 = menuLists.iterator(); iterator1.hasNext();)
			{
				Menu menu = (Menu)iterator1.next();
				if (pmsControl)
					menuDTOLists.add((new MenuDTO()).transfer(menu, pmsMenuBindNavIds));
				else
					menuDTOLists.add((new MenuDTO()).transfer(menu));
			}

		}
		nodeSystemDTO.reloadTree(menuDTOLists);
		return nodeSystemDTO;
	}

	public TreeNavigationTree getPmsTreeNavigation(String userId, String nodeSystemCode, String menuId, String menuNavId, String navControlId)
	{
		User user = (User)userDao.getById(userId);
		boolean pmsControl = true;
		StringBuffer roleStr = new StringBuffer();
		Set pmsTreeNavIds = Sets.newHashSet();
		if (com.hfstu.pms.model.User.UserSuperAdminEnum.ADMIN.getKey().equals(String.valueOf(user.getSuperAdmin())))
		{
			pmsControl = false;
		} else
		{
			Set roles = user.getRoles();
			if (roles != null)
			{
				Role role;
				for (Iterator iterator = roles.iterator(); iterator.hasNext(); roleStr.append(role.getId()).append(","))
					role = (Role)iterator.next();

				if (!StringUtil.isNullOrEmpty(roleStr.toString()) && roleStr.charAt(roleStr.length() - 1) == ',')
					roleStr.deleteCharAt(roleStr.length() - 1);
			}
			Map resourceMap = loadHasPms(roleStr.toString(), nodeSystemCode, PmsCombinationType.ROLE_RESOURCE.getKey(), menuId);
			pmsTreeNavIds = (Set)resourceMap.get(PmsResourceType.NAVIGATION.getKey());
		}
		Map queryMap = Maps.newHashMap();
		queryMap.put("menuId", menuId);
		queryMap.put("navControlId", navControlId);
		TreeNavigationTree tnt = TreeNavigationTree.getInstance();
		if (pmsControl)
			tnt.reloadPmsTreeNavigationTree(queryMap, pmsTreeNavIds, menuId, menuNavId);
		else
			tnt.reloadTreeNavigationTree(queryMap);
		return tnt;
	}

	public List getPmsListNavigation(String userId, String nodeSystemCode, String menuId, String menuNavId, String navControlId)
	{
		User user = (User)userDao.getById(userId);
		boolean pmsControl = true;
		StringBuffer roleStr = new StringBuffer();
		Set pmsListNavIds = Sets.newHashSet();
		if (com.hfstu.pms.model.User.UserSuperAdminEnum.ADMIN.getKey().equals(String.valueOf(user.getSuperAdmin())))
		{
			pmsControl = false;
		} else
		{
			Set roles = user.getRoles();
			if (roles != null)
			{
				Role role;
				for (Iterator iterator = roles.iterator(); iterator.hasNext(); roleStr.append(role.getId()).append(","))
					role = (Role)iterator.next();

				if (!StringUtil.isNullOrEmpty(roleStr.toString()) && roleStr.charAt(roleStr.length() - 1) == ',')
					roleStr.deleteCharAt(roleStr.length() - 1);
			}
			Map resourceMap = loadHasPms(roleStr.toString(), nodeSystemCode, PmsCombinationType.ROLE_RESOURCE.getKey(), menuId);
			pmsListNavIds = (Set)resourceMap.get(PmsResourceType.NAVIGATION.getKey());
		}
		Map queryMap = Maps.newHashMap();
		queryMap.put("menuId", menuId);
		queryMap.put("listNavigation.navControl.id", navControlId);
		Map sortMap = Maps.newHashMap();
		queryMap.put("orderIndex", "ASC");
		List listNavigations = listNavigationDao.findListByCondition(queryMap, sortMap);
		List listNavigationDTOs = Lists.newArrayList();
		String navId = null;
		for (Iterator iterator1 = listNavigations.iterator(); iterator1.hasNext();)
		{
			ListNavigation listNavigation = (ListNavigation)iterator1.next();
			if (pmsControl)
			{
				if (pmsListNavIds != null && pmsListNavIds.size() != 0)
				{
					navId = (new StringBuilder(String.valueOf(listNavigation.getId()))).append("_").append(menuNavId).append("_").append(menuId).toString();
					if (pmsListNavIds.contains(navId))
						listNavigationDTOs.add((new ListNavigationDTO()).transfer(listNavigation));
				}
			} else
			{
				listNavigationDTOs.add((new ListNavigationDTO()).transfer(listNavigation));
			}
		}

		return listNavigationDTOs;
	}

	public Map loadHasPms(String nodeId, String systemCode, String combinationType, String menuId)
	{
		Map map = Maps.newHashMap();
		Map filterPropertyMap = Maps.newHashMap();
		filterPropertyMap.put("pmsResource.combinationType", combinationType);
		filterPropertyMap.put("pmsResource.systemCode", systemCode);
		if (!StringUtil.isNullOrEmpty(nodeId))
		{
			if (nodeId.split(",").length > 1)
				filterPropertyMap.put("pmsResource.nodeIds", nodeId.split(","));
			else
				filterPropertyMap.put("pmsResource.nodeId", nodeId);
		} else
		{
			filterPropertyMap.put("pmsResource.nodeId", "-1");
		}
		if (!StringUtil.isNullOrEmpty(menuId))
			filterPropertyMap.put("pmsResource.menuId", menuId);
		List pmsResources = pmsResourceDao.findListByCondition(filterPropertyMap, null);
		String resoureType = null;
		String resoureId = null;
		Iterator iterator = pmsResources.iterator();
		while (iterator.hasNext()) 
		{
			PmsResource pmsResource = (PmsResource)iterator.next();
			resoureType = pmsResource.getResourceType();
			if (PmsResourceType.MENU.getKey().equals(resoureType))
				resoureId = pmsResource.getMenuId();
			else
			if (PmsResourceType.MENUNAV.getKey().equals(resoureType))
				resoureId = pmsResource.getMenuNavId();
			else
			if (PmsResourceType.NAVCONTROL.getKey().equals(resoureType))
				resoureId = (new StringBuilder(String.valueOf(pmsResource.getNavControlId()))).append("_").append(pmsResource.getMenuNavId()).append("_").append(pmsResource.getMenuId()).toString();
			else
			if (PmsResourceType.NAVIGATION.getKey().equals(resoureType))
				resoureId = (new StringBuilder(String.valueOf(pmsResource.getNavId()))).append("_").append(pmsResource.getMenuNavId()).append("_").append(pmsResource.getMenuId()).toString();
			else
			if (!PmsResourceType.CONTROLREGISTER.getKey().equals(resoureType))
			{
				if (!PmsResourceType.CONTROLFUNC.getKey().equals(resoureType))
					continue;
				if (StringUtil.isNullOrEmpty(pmsResource.getNavId()))
					resoureId = (new StringBuilder(String.valueOf(pmsResource.getControlFuncId()))).append("_").append(pmsResource.getMenuId()).toString();
				else
					resoureId = (new StringBuilder(String.valueOf(pmsResource.getControlFuncId()))).append("_").append(pmsResource.getNavId()).append("_").append(pmsResource.getMenuNavId()).append("_").append(pmsResource.getMenuId()).toString();
			}
			if (map.get(resoureType) != null)
				((Set)map.get(resoureType)).add(resoureId);
			else
				map.put(resoureType, Sets.newHashSet(new String[] {
					resoureId
				}));
		}
		return map;
	}

	public List loadAllResource(String systemCode)
	{
		Map sortValueMap = Maps.newHashMap();
		sortValueMap.put("orderIndex", "ASC");
		List treeObjects = Lists.newArrayList();
		List nodeSystems = nodeSystemDao.getByCodes(Lists.newArrayList(new String[] {
			systemCode
		}));
		NodeSystem nodeSystem;
		for (Iterator iterator = nodeSystems.iterator(); iterator.hasNext(); treeObjects.add((new Res_NodeSystemDTO()).transfer(nodeSystem)))
			nodeSystem = (NodeSystem)iterator.next();

		Map filterPropertyMap = new HashMap();
		filterPropertyMap.put("sd.code", systemCode);
		Map sortMap = Maps.newHashMap();
		sortMap.put("menu.orderIndex", "ASC");
		List menus = menuDao.findListByCondition(filterPropertyMap, sortMap);
		List menuIds = Lists.newArrayList();
		List funcDefIds = Lists.newArrayList();
		Menu menu;
		for (Iterator iterator1 = menus.iterator(); iterator1.hasNext(); treeObjects.add((new Res_MenuDTO()).transfer(menu)))
		{
			menu = (Menu)iterator1.next();
			if (!menuIds.contains(menu.getId()))
				menuIds.add(menu.getId());
			if (menu.getFuncDef() != null && !funcDefIds.contains(menu.getFuncDef().getId()))
				funcDefIds.add(menu.getFuncDef().getId());
		}

		List menuBindNavs = menuBindNavDao.findListByCondition(null, sortValueMap);
		Map menuBindNavMap = Maps.newHashMap();
		List navControlIds = Lists.newArrayList();
		for (Iterator iterator2 = menuBindNavs.iterator(); iterator2.hasNext();)
		{
			MenuBindNav menuBindNav = (MenuBindNav)iterator2.next();
			if (menuIds.contains(menuBindNav.getMenu().getId()))
			{
				if (menuBindNavMap.get(menuBindNav.getMenu().getId()) != null)
					((List)menuBindNavMap.get(menuBindNav.getMenu().getId())).add((new Res_MenuNavDTO()).transfer(menuBindNav));
				else
					menuBindNavMap.put(menuBindNav.getMenu().getId(), Lists.newArrayList(new Res_MenuNavDTO[] {
						(new Res_MenuNavDTO()).transfer(menuBindNav)
					}));
				if (!navControlIds.contains(menuBindNav.getNavControl().getId()))
					navControlIds.add(menuBindNav.getNavControl().getId());
			}
		}

		List navControls = navControlDao.findListByCondition(null, null);
		Map navControlMap = Maps.newHashMap();
		for (Iterator iterator3 = navControls.iterator(); iterator3.hasNext();)
		{
			NavControl navControl = (NavControl)iterator3.next();
			if (navControlIds.contains(navControl.getId()))
				navControlMap.put(navControl.getId(), (new Res_NavControlDTO()).transfer(navControl));
		}

		List treeNavigations = treeNavigationDao.findListByCondition(null, sortValueMap);
		Map treeNavigationMap = Maps.newHashMap();
		for (Iterator iterator4 = treeNavigations.iterator(); iterator4.hasNext();)
		{
			TreeNavigation treeNavigation = (TreeNavigation)iterator4.next();
			if (navControlIds.contains(treeNavigation.getNavControl().getId()))
			{
				if (treeNavigationMap.get(treeNavigation.getNavControl().getId()) != null)
					((List)treeNavigationMap.get(treeNavigation.getNavControl().getId())).add((new Res_TreeNavDTO()).transfer(treeNavigation));
				else
					treeNavigationMap.put(treeNavigation.getNavControl().getId(), Lists.newArrayList(new Res_TreeNavDTO[] {
						(new Res_TreeNavDTO()).transfer(treeNavigation)
					}));
				if (treeNavigation.getFuncDef() != null && !funcDefIds.contains(treeNavigation.getFuncDef().getId()))
					funcDefIds.add(treeNavigation.getFuncDef().getId());
			}
		}

		List listNavigations = listNavigationDao.findListByCondition(null, sortValueMap);
		Map listNavigationMap = Maps.newHashMap();
		for (Iterator iterator5 = listNavigations.iterator(); iterator5.hasNext();)
		{
			ListNavigation listNavigation = (ListNavigation)iterator5.next();
			if (navControlIds.contains(listNavigation.getNavControl().getId()))
			{
				if (listNavigationMap.get(listNavigation.getNavControl().getId()) != null)
					((List)listNavigationMap.get(listNavigation.getNavControl().getId())).add((new Res_ListNavDTO()).transfer(listNavigation));
				else
					listNavigationMap.put(listNavigation.getNavControl().getId(), Lists.newArrayList(new Res_ListNavDTO[] {
						(new Res_ListNavDTO()).transfer(listNavigation)
					}));
				if (!funcDefIds.contains(listNavigation.getFuncDef().getId()))
					funcDefIds.add(listNavigation.getFuncDef().getId());
			}
		}

		List funcLayouts = funcLayoutDao.findListByCondition(null, null);
		Map funcLayoutMap = Maps.newHashMap();
		List controlRegisterIds = Lists.newArrayList();
		for (Iterator iterator6 = funcLayouts.iterator(); iterator6.hasNext();)
		{
			FuncLayout funcLayout = (FuncLayout)iterator6.next();
			if (funcDefIds.contains(funcLayout.getFuncDef().getId()))
			{
				funcLayoutMap.put(funcLayout.getFuncDef().getId(), funcLayout);
				if (funcLayout.getControlRegister() != null && !controlRegisterIds.contains(funcLayout.getControlRegister().getId()))
					controlRegisterIds.add(funcLayout.getControlRegister().getId());
			}
		}

		List controlRegisters = controlRegisterDao.findListByCondition(null, sortValueMap);
		Map controlRegisterMap = Maps.newHashMap();
		for (Iterator iterator7 = controlRegisters.iterator(); iterator7.hasNext();)
		{
			ControlRegister controlRegister = (ControlRegister)iterator7.next();
			if (controlRegisterIds.contains(controlRegister.getId()))
				controlRegisterMap.put(controlRegister.getId(), (new Res_ControlRegisterDTO()).transfer(controlRegister));
		}

		List controlFuncs = controlFuncDao.findListByCondition(null, null);
		Map controlFuncMap = Maps.newHashMap();
		for (Iterator iterator8 = controlFuncs.iterator(); iterator8.hasNext();)
		{
			ControlFunc controlFunc = (ControlFunc)iterator8.next();
			if (controlRegisterIds.contains(controlFunc.getControlRegister().getId()))
				if (controlFuncMap.get(controlFunc.getControlRegister().getId()) != null)
					((List)controlFuncMap.get(controlFunc.getControlRegister().getId())).add((new Res_ControlFuncDTO()).transfer(controlFunc));
				else
					controlFuncMap.put(controlFunc.getControlRegister().getId(), Lists.newArrayList(new Res_ControlFuncDTO[] {
						(new Res_ControlFuncDTO()).transfer(controlFunc)
					}));
		}

		String funcDefId = null;
		String menuNavFunDefContrFuncId = null;
		for (Iterator iterator9 = menus.iterator(); iterator9.hasNext();)
		{
			Menu menu = (Menu)iterator9.next();
			String menuId = menu.getId();
			if (menu.getFuncDef() != null)
			{
				funcDefId = menu.getFuncDef().getId();
				loadControl(menuId, null, funcDefId, funcLayoutMap, controlRegisterMap, controlFuncMap, treeObjects);
			}
			List res_MenuNavDTOs = (List)menuBindNavMap.get(menuId);
			if (res_MenuNavDTOs != null && res_MenuNavDTOs.size() != 0)
			{
				for (Iterator iterator10 = res_MenuNavDTOs.iterator(); iterator10.hasNext();)
				{
					Res_MenuNavDTO res_MenuNavDTO = (Res_MenuNavDTO)iterator10.next();
					menuNavFunDefContrFuncId = (new StringBuilder(String.valueOf(res_MenuNavDTO.getId()))).append("_").append(res_MenuNavDTO.getMenuId()).toString();
					Res_MenuNavDTO new_Res_MenuNavDTO = (Res_MenuNavDTO)res_MenuNavDTO.clone();
					new_Res_MenuNavDTO.setParentId(menuId);
					treeObjects.add(new_Res_MenuNavDTO);
					Res_NavControlDTO res_NavControlDTO = (Res_NavControlDTO)navControlMap.get(res_MenuNavDTO.getNavControlId());
					if (res_NavControlDTO != null)
					{
						Res_NavControlDTO new_Res_NavControlDTO = (Res_NavControlDTO)res_NavControlDTO.clone();
						new_Res_NavControlDTO.setId((new StringBuilder(String.valueOf(res_NavControlDTO.getId()))).append("_").append(menuNavFunDefContrFuncId).toString());
						new_Res_NavControlDTO.setParentId(res_MenuNavDTO.getId());
						treeObjects.add(new_Res_NavControlDTO);
					}
					if (com.hfstu.ifs.model.NavControl.NavControlTypeEnum.TREENAV.getKey().equals(res_MenuNavDTO.getNavControlType()))
					{
						List res_TreeNavDTOs = (List)treeNavigationMap.get(res_MenuNavDTO.getNavControlId());
						if (res_TreeNavDTOs != null && res_TreeNavDTOs.size() != 0)
						{
							Res_TreeNavDTO res_TreeNavDTO;
							for (Iterator iterator11 = res_TreeNavDTOs.iterator(); iterator11.hasNext(); loadControl(menuNavFunDefContrFuncId, res_TreeNavDTO.getId(), funcDefId, funcLayoutMap, controlRegisterMap, controlFuncMap, treeObjects))
							{
								res_TreeNavDTO = (Res_TreeNavDTO)iterator11.next();
								Res_TreeNavDTO new_Res_TreeNavDTO = (Res_TreeNavDTO)res_TreeNavDTO.clone();
								new_Res_TreeNavDTO.setId((new StringBuilder(String.valueOf(new_Res_TreeNavDTO.getId()))).append("_").append(menuNavFunDefContrFuncId).toString());
								if (new_Res_TreeNavDTO.getParentId().equals(new_Res_TreeNavDTO.getNavControlId()))
									new_Res_TreeNavDTO.setParentId((new StringBuilder(String.valueOf(res_NavControlDTO.getId()))).append("_").append(menuNavFunDefContrFuncId).toString());
								else
									new_Res_TreeNavDTO.setParentId((new StringBuilder(String.valueOf(new_Res_TreeNavDTO.getParentId()))).append("_").append(menuNavFunDefContrFuncId).toString());
								treeObjects.add(new_Res_TreeNavDTO);
								funcDefId = res_TreeNavDTO.getFuncDefId();
							}

						}
					} else
					if (com.hfstu.ifs.model.NavControl.NavControlTypeEnum.LISTNAV.getKey().equals(res_MenuNavDTO.getNavControlType()))
					{
						List res_ListNavDTOs = (List)listNavigationMap.get(res_MenuNavDTO.getNavControlId());
						if (res_ListNavDTOs != null && res_ListNavDTOs.size() != 0)
						{
							Res_ListNavDTO res_ListNavDTO;
							for (Iterator iterator12 = res_ListNavDTOs.iterator(); iterator12.hasNext(); loadControl(menuNavFunDefContrFuncId, res_ListNavDTO.getId(), funcDefId, funcLayoutMap, controlRegisterMap, controlFuncMap, treeObjects))
							{
								res_ListNavDTO = (Res_ListNavDTO)iterator12.next();
								Res_ListNavDTO new_Res_ListNavDTO = (Res_ListNavDTO)res_ListNavDTO.clone();
								new_Res_ListNavDTO.setId((new StringBuilder(String.valueOf(new_Res_ListNavDTO.getId()))).append("_").append(menuNavFunDefContrFuncId).toString());
								new_Res_ListNavDTO.setParentId((new StringBuilder(String.valueOf(res_NavControlDTO.getId()))).append("_").append(menuNavFunDefContrFuncId).toString());
								treeObjects.add(new_Res_ListNavDTO);
								funcDefId = res_ListNavDTO.getFuncDefId();
							}

						}
					}
				}

			}
		}

		return treeObjects;
	}

	public ResourceTree loadRoleAllResource(String roleId, String systemCode)
	{
		ResourceTree rt = new ResourceTree();
		List treeObjects = loadAllResource(systemCode);
		Map resourceMap = loadHasPms(roleId, systemCode, PmsCombinationType.ROLE_RESOURCE.getKey(), null);
		rt.reloadTree(treeObjects, resourceMap);
		return rt;
	}

	public ResourceTree loadUserAllResource(String userId, String systemCode)
	{
		User user = (User)userDao.getById(userId);
		boolean pmsControl = true;
		StringBuffer roleStr = new StringBuffer();
		if (com.hfstu.pms.model.User.UserSuperAdminEnum.ADMIN.getKey().equals(String.valueOf(user.getSuperAdmin())))
		{
			pmsControl = false;
		} else
		{
			Set roles = user.getRoles();
			if (roles != null)
			{
				Role role;
				for (Iterator iterator = roles.iterator(); iterator.hasNext(); roleStr.append(role.getId()).append(","))
					role = (Role)iterator.next();

				if (!StringUtil.isNullOrEmpty(roleStr.toString()) && roleStr.charAt(roleStr.length() - 1) == ',')
					roleStr.deleteCharAt(roleStr.length() - 1);
			}
		}
		ResourceTree rt = new ResourceTree();
		List treeObjects = loadAllResource(systemCode);
		if (pmsControl)
		{
			Map resourceMap = loadHasPms(roleStr.toString(), systemCode, PmsCombinationType.ROLE_RESOURCE.getKey(), null);
			rt.reloadTree(treeObjects, resourceMap);
			return rt;
		} else
		{
			rt.reloadTree(treeObjects);
			return rt;
		}
	}

	private void loadControl(String menuId, String navigationId, String funcDefId, Map funcLayoutMap, Map controlRegisterMap, Map controlFuncMap, List treeObjects)
	{
		String controlRegisterId = null;
		FuncLayout funcLayout = (FuncLayout)funcLayoutMap.get(funcDefId);
		if (funcLayout != null)
		{
			controlRegisterId = funcLayout.getControlRegister() == null ? null : funcLayout.getControlRegister().getId();
			Res_ControlRegisterDTO res_ControlRegisterDTO = (Res_ControlRegisterDTO)controlRegisterMap.get(controlRegisterId);
			if (res_ControlRegisterDTO != null)
			{
				Res_ControlRegisterDTO new_Res_ControlRegisterDTO = (Res_ControlRegisterDTO)res_ControlRegisterDTO.clone();
				new_Res_ControlRegisterDTO.setId((new StringBuilder(String.valueOf(new_Res_ControlRegisterDTO.getId()))).append("_").append(menuId).toString());
				new_Res_ControlRegisterDTO.setParentId(StringUtil.isNullOrEmpty(navigationId) ? menuId : (new StringBuilder(String.valueOf(navigationId))).append("_").append(menuId).toString());
			}
			List res_ControlFuncDTOs = (List)controlFuncMap.get(controlRegisterId);
			if (res_ControlFuncDTOs != null && res_ControlFuncDTOs.size() != 0)
			{
				Res_ControlFuncDTO new_Res_ControlFuncDTO;
				for (Iterator iterator = res_ControlFuncDTOs.iterator(); iterator.hasNext(); treeObjects.add(new_Res_ControlFuncDTO))
				{
					Res_ControlFuncDTO res_ControlFuncDTO = (Res_ControlFuncDTO)iterator.next();
					new_Res_ControlFuncDTO = (Res_ControlFuncDTO)res_ControlFuncDTO.clone();
					new_Res_ControlFuncDTO.setId((new StringBuilder(String.valueOf(new_Res_ControlFuncDTO.getId()))).append("_").append(StringUtil.isNullOrEmpty(navigationId) ? menuId : (new StringBuilder(String.valueOf(navigationId))).append("_").append(menuId).toString()).toString());
					new_Res_ControlFuncDTO.setParentId(StringUtil.isNullOrEmpty(navigationId) ? menuId : (new StringBuilder(String.valueOf(navigationId))).append("_").append(menuId).toString());
				}

			}
		}
	}

	public IUserDao getUserDao()
	{
		return userDao;
	}

	public void setUserDao(IUserDao userDao)
	{
		this.userDao = userDao;
	}

	public IPmsResourceDao getPmsResourceDao()
	{
		return pmsResourceDao;
	}

	public void setPmsResourceDao(IPmsResourceDao pmsResourceDao)
	{
		this.pmsResourceDao = pmsResourceDao;
	}

	public INavControlDao getNavControlDao()
	{
		return navControlDao;
	}

	public void setNavControlDao(INavControlDao navControlDao)
	{
		this.navControlDao = navControlDao;
	}

	public IListNavigationDao getListNavigationDao()
	{
		return listNavigationDao;
	}

	public void setListNavigationDao(IListNavigationDao listNavigationDao)
	{
		this.listNavigationDao = listNavigationDao;
	}

	public ITreeNavigationDao getTreeNavigationDao()
	{
		return treeNavigationDao;
	}

	public void setTreeNavigationDao(ITreeNavigationDao treeNavigationDao)
	{
		this.treeNavigationDao = treeNavigationDao;
	}

	public IControlFuncDao getControlFuncDao()
	{
		return controlFuncDao;
	}

	public void setControlFuncDao(IControlFuncDao controlFuncDao)
	{
		this.controlFuncDao = controlFuncDao;
	}

	public IControlRegisterDao getControlRegisterDao()
	{
		return controlRegisterDao;
	}

	public void setControlRegisterDao(IControlRegisterDao controlRegisterDao)
	{
		this.controlRegisterDao = controlRegisterDao;
	}

	public IMenuBindNavDao getMenuBindNavDao()
	{
		return menuBindNavDao;
	}

	public void setMenuBindNavDao(IMenuBindNavDao menuBindNavDao)
	{
		this.menuBindNavDao = menuBindNavDao;
	}

	public IMenuDao getMenuDao()
	{
		return menuDao;
	}

	public void setMenuDao(IMenuDao menuDao)
	{
		this.menuDao = menuDao;
	}

	public INodeSystemDao getNodeSystemDao()
	{
		return nodeSystemDao;
	}

	public void setNodeSystemDao(INodeSystemDao nodeSystemDao)
	{
		this.nodeSystemDao = nodeSystemDao;
	}

	public IFuncLayoutDao getFuncLayoutDao()
	{
		return funcLayoutDao;
	}

	public void setFuncLayoutDao(IFuncLayoutDao funcLayoutDao)
	{
		this.funcLayoutDao = funcLayoutDao;
	}
}
